home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / Libraries / SAT 2.4.0 / SAT / Demo ƒ / Collision demo ƒ / Collision.p < prev    next >
Encoding:
Text File  |  1995-09-11  |  1.4 KB  |  55 lines  |  [TEXT/PJMM]

  1. {*****************************}
  2. {********* SAT Collision **********}
  3. {*****************************}
  4.  
  5. {A SAT demo that is slightly over SATminimal, demonstrating the simplest}
  6. {collision handling based on the kind field (KindCollision).}
  7.  
  8. program SATcollision;
  9.  
  10.     uses
  11. {$ifc UNDEFINED THINK_PASCAL}
  12.         Types, QuickDraw, Events, Windows, Dialogs, Fonts, DiskInit, TextEdit,{}
  13.         Traps, Memory, SegLoad, Scrap, ToolUtils, OSUtils, Menus,{}
  14.         Resources, StandardFile, GestaltEqu, Files, Errors, 
  15. {$endc}
  16.         SAT, sMrEgghead, sApple;
  17.  
  18.     var
  19.         ignoreSp: SpritePtr;
  20.         l: longint;
  21.         p: Point;
  22. begin
  23. {Standard Inits are done by Think Pascal.}
  24. {$IFC UNDEFINED THINK_PASCAL}
  25.     SATInitToolbox;
  26. {$ENDC}
  27.  
  28. {Initialize SAT}
  29.     SATConfigure(true, kVPositionSort, kKindCollision, 32);
  30.     SATInit(128, 129, 512, 322);
  31.  
  32. {Initialize sprite units}
  33.     InitMrEgghead;
  34.     InitApple;
  35.  
  36. {Make sprites}
  37.     GetMouse(p); {We get the mouse position in order to put Mr Egghead under it immediately}
  38.     ignoreSp := SATNewSprite(0, p.h, p.v, @SetupMrEgghead);
  39.     ignoreSp := SATNewSprite(0, 0, SATRand(gSAT.offSizeV - 32), @SetupApple);
  40.  
  41.     HideCursor;
  42.  
  43.     repeat
  44.         l := TickCount;
  45.         SATRun(true); {Run a frame of animation}
  46.         while l > TickCount - 3 do {Speed limit}
  47.             ;
  48.  
  49. {Start a new apple once in a while}
  50.         if SATRand(40) = 1 then
  51.             ignoreSp := SATNewSprite(0, 0, SATRand(gSAT.offSizeV - 32), @SetupApple);
  52.     until Button;
  53.     ShowCursor;
  54.     SATSoundShutUp; {Always make sure the sound channel is de-allocated!}
  55. end.